/********************************************************
 Name          : main.c
 Author        : Nipun Batra
 Copyright     : Apache 2
 Description   : Turn on LED1 when Push Button PB0 is pressed
 **********************************************************/

// Include Files 
#include "board.h"

#include "gpio.h"


int main(void) {
	int i;
	AVR32_GPIO.port[1].gpers = 2 <<24;

	while(1)
	{
		i=(AVR32_GPIO.port[2].pvr >> 24) & 0x01; //read port value register
		if(i==0)//Push button is pressed,then clear pin corresponding to led1
			//NB :Even though i will become 1,still the LED will remain on since we are not setting the corresponding pin back
		{
			AVR32_GPIO.port[1].gpers = 1 <<27; //enable GPIO control
			AVR32_GPIO.port[1].oders = 1 <<27; //enable output driver
			AVR32_GPIO.port[1].ovrc = 1 <<27; //clear value of pin
		}

	}
}
